<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <title>销售综合报表,航空公司版</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    </head>
    <body>
        <div id='report_airways_form_div'>
        </div>
        <script>
            Ext.onReady(function(){
                var airways = new Ext.form.ComboBox({
                    store: new Ext.data.Store({
                        proxy: new Ext.data.HttpProxy({
                            url: '/admin/getInternalAirways'
                        }),
                        reader: new Ext.data.JsonReader({
                            root: 'root',
                            id: 'id'
                        }, ['airways_code', 'airways_name'])
                    }),
                    name: 'card_type',
                    loadingText: '正在加载...',
                    //displayField: 'customer_type',
                    displayField: 'airways_name',
                    valueField: 'airways_code',
                    mode: 'remote',
                    triggerAction: 'all',
                    hiddenName: 'airways_code',//如果不想提交displayField，则在这儿指定以提交ID的值．
                    //hiddenId:'type_id',
                    fieldLabel: '航空公司',
                    emptyText: '请选择...',
                    editable: false,
                    allowBlank: false,
                    width: 100,
                    maxHeight: 150,
                    tabIndex: 4
                });
                var airwaysDateBegin = new Ext.form.DateField({
                    fieldLabel: '日期从',
                    name: 'airways_datebegin',
                    id: 'airways_datebegin',
                    format: 'Y-m-d', //格式化日期   
                    width: '100',
                    //disabledDays: [0,6],	//不让选择周六，周日   
                    //disabledDaysText: "周末要休息",   
                    invalidText: "您输入的日期格式不对，正确格式为2008-01-01",
                    allowBlank: true,
                    inputType: '2008-01-01',
                    anchor: '90%',
                    vtype: 'daterange',
                    endDateField: 'airways_dateend',
                    allowBlank: false,
                    listeners: {
                        select: function(field, e){
                            Ext.MessageBox.alert('提示', '提交成功');
                        }
                    }//,
                    //onTriggerClick:function(){Ext.MessageBox.alert('提示', '提交成功');}
                    //value:'1975-01-01'
                    //maxValue:'1925-01-01'
                });
                var airwaysDateEnd = new Ext.form.DateField({
                    fieldLabel: '到',
                    name: 'airways_dateend',
                    id: 'airways_dateend',
                    format: 'Y-m-d', //格式化日期   
                    width: '100',
                    //disabledDays: [0,6],	//不让选择周六，周日   
                    //disabledDaysText: "周末要休息",   
                    invalidText: "您输入的日期格式不对，正确格式为2008-01-01",
                    allowBlank: true,
                    inputType: '2008-01-01',
                    anchor: '90%',
                    vtype: 'daterange',
                    startDateField: 'airways_datebegin',
                    allowBlank: false,
                    listeners: {
                        select: function(field, e){
                            Ext.MessageBox.alert('提示', '提交成功');
                        }
                    }//,
                    //onTriggerClick:function(){Ext.MessageBox.alert('提示', '提交成功');}
                    //value:'1975-01-01'
                    //maxValue:'1925-01-01'
                });
                var searchButton = new Ext.Button({
                    text: '生成报表',
                    handler: reportByAirways
                });
                var reportAirwaysFormPanel = new Ext.form.FormPanel({
                    baseCls: 'x-plain',
                    labelWidth: 55,
                    width: '650',
                    //url: '/reports/dailySellReport',
                    //defaultType: 'textfield',
                    items: [{
                        layout: 'column',
                        border: false,
                        items: [{
                            columnWidth: .29,
                            layout: 'form',
                            border: false,
                            items: [airways]
                        }, {
                            columnWidth: .29,
                            layout: 'form',
                            border: false,
                            items: [airwaysDateBegin]
                        }, {
                            columnWidth: .29,
                            layout: 'form',
                            border: false,
                            items: [airwaysDateEnd]
                        }, {
                            columnWidth: .13,
                            layout: 'form',
                            border: false,
                            items: [searchButton]
                        }]
                    }]
                });
                reportAirwaysFormPanel.render('report_airways_form_div');
                function reportByAirways(){
                    if (reportAirwaysFormPanel.form.isValid()) {
                        Ext.Ajax.request({
                            url: '/reports/reportByAirways',
                            params: reportAirwaysFormPanel.form.getValues(true),
                            method: 'GET',
                            success: function(result, request){
                                Ext.MessageBox.alert('报表提示', result.responseText);
                            },
                            failure: function(result, request){
                                Ext.MessageBox.alert('Failed', 'Not be found!');
                            }
                        });
                    }
                }
            });
        </script>
    </body>
</html>
